package org.example.Server.controller.question;

import lombok.extern.slf4j.Slf4j;
import org.example.Server.model.question.QsStarDTO;
import org.example.Server.model.question.QsStarVO;
import org.example.Server.service.question.QuestionService;
import org.example.Server.utils.ResultAPI;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Slf4j
@RequestMapping("/youxich/question/stu")
public class QsStuController {
    @Autowired
    QuestionService questionService;

    /**
     * 获取学生收藏的试题
     *
     * @param user_id
     * @return
     */
    @GetMapping
    public ResultAPI getStuQsList(@RequestParam Integer user_id,
                                  @RequestParam(required = false) Integer qs_type,
                                  @RequestParam(required = false) Integer difficulty,
                                  @RequestParam(required = false) Integer point_id) {
        return questionService.getStuQsList(user_id, qs_type, difficulty, point_id);
    }

    /**
     * 学生收藏试题
     *
     * @param qsStarDTO
     * @return
     */
    @PostMapping
    public ResultAPI addStuStarQs(@RequestBody QsStarDTO qsStarDTO) {
        return questionService.addStuStarQs(qsStarDTO);
    }

    /**
     * 学生删除星标试题
     *
     * @param ids
     * @return
     */
    @DeleteMapping("{ids}")
    public ResultAPI deleteStuQsById(@PathVariable List<Integer> ids) {
        return questionService.deleteStuQsById(ids);
    }
}
